/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.fedoraaccess.metadataUpdate.object;

import cz.mzk.kramerius.fedoraaccess.FedoraConnector;
import cz.mzk.kramerius.fedoraaccess.metadataUpdate.datastream.DatastreamUpdater;
import cz.mzk.kramerius.fedoraaccess.metadataUpdate.datastream.DcTypeModelUpdater;
import cz.mzk.kramerius.fedoraaccess.metadataUpdate.datastream.RelsExtModelUpdater;
import cz.mzk.rehan.commons.Model;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Martin Řehánek <rehan at mzk.cz>
 */
public class ModelChanger extends ObjectUpdater {

    private static final Logger logger = Logger.getLogger(ModelChanger.class.getName());
    private final DatastreamUpdater dcTypeModelUpdater;
    private final DatastreamUpdater relsExtModelUpdater;

    public ModelChanger(FedoraConnector con, Model newModel) {
        super(con);
        this.dcTypeModelUpdater = new DcTypeModelUpdater(con, newModel);
        this.relsExtModelUpdater = new RelsExtModelUpdater(con, newModel);
    }

    @Override
    public void updateObject(String pid) throws Exception {
        dcTypeModelUpdater.updateDatastream(pid);
        logger.log(Level.INFO, "model updated in DC datastream");
        relsExtModelUpdater.updateDatastream(pid);
        logger.log(Level.INFO, "model updated in RELS-EXT datastream");
    }
}
